#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_file.py
# author:张世航
# datetime:2024/11/9 17:44
# software: PyCharm
"""
this is function  description 
"""
# import module your need

def create_file():
    # 创建文件并写入初始内容
    content = [
        "How many roads must a man walk down",
        "Before they call him a man",
        "How many seas must a white dove sail",
        "Before she sleeps in the sand",
        "How many times must the cannon balls fly",
        "Before they're forever banned",
        "The answer my friend is blowing in the wind",
        "The answer is blowing in the wind"
    ]

    # 将内容写入文件
    with open("Blowing in the wind.txt", "w", encoding="utf-8") as file:
        for line in content:
            file.write(line + "\n")

def insert_content():
    # 读取文件内容
    with open("Blowing in the wind.txt", "r", encoding="utf-8") as file:
        lines = file.readlines()

    # 在文件头部插入歌名
    lines.insert(0, "Blowin' in the wind\n")
    # 在歌名后插入歌手名
    lines.insert(1, "Bob Dylan\n")

    # 在文件末尾加上字符串
    lines.append("1962 by Warner Bros. Inc.\n")

    # 将修改后的内容写回文件
    with open("Blowing in the wind.txt", "w", encoding="utf-8") as file:
        file.writelines(lines)

def print_file_content():
    # 打印文件内容
    with open("Blowing in the wind.txt", "r", encoding="utf-8") as file:
        content = file.read()
        print(content)

# 执行程序
create_file()
insert_content()
print_file_content()